package com.example.riceexambackend.dao.mapper;

import com.example.riceexambackend.dao.dataobject.UserDO;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {

    /**
     * 根据账号查询总数
     * @param userAccount
     * @return
     */
    @Select("select count(*) from t_user where user_account = #{userAccount}")
    int countByAccount(@Param("userAccount") String userAccount);

    /**
     * 根据账号查询总数
     * @param userAccount
     * @return
     */
    @Select("select * from t_user where user_account = #{userAccount}")
    UserDO selectByAccount(@Param("userAccount") String userAccount);

    /**
     * 插入用户记录
     * @param userDO
     */
    @Insert("insert into t_user (user_account, user_pwd) values (#{userAccount}, #{userPwd})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void insertUser(UserDO userDO);

    /**
     * 根据id查询用户
     * @param userId
     */
    @Select("select * from t_user where id = #{userId}")
    UserDO selectById(@Param("userId") Long userId);

//    @Select("select count(*) from user where email = #{email}")
//    int countByMail(@Param("email") String email);
//
//    @Select("select count(*) from user where phone_number = #{phoneNumber}")
//    int countByPhone(@Param("phoneNumber") PhoneNumberEncrypt phoneNumber);
//
//    @Insert("insert into user (user_name, email, phone_number, password, identity) values" +
//            " (#{userName}, #{email}, #{phoneNumber}, #{password}, #{identity})")
//    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
//    void insertUser(UserDO userDO);
//
//    @Select("select * from user where id = #{id}")
//    UserDO findById(@Param("id") Long id);
//
//    @Select("select * from user where phone_number = #{phoneNumber}")
//    UserDO selectByPhoneNumber(@Param("phoneNumber") PhoneNumberEncrypt phoneNumber);
//
//    @Select("select * from user where email = #{email}")
//    UserDO selectByMail(@Param("email") String email);
}
